package com.ruoyi.web.controller.system;

import java.util.List;

import com.sun.org.apache.xpath.internal.operations.Mod;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysProvidecontractdetails;
import com.ruoyi.system.service.ISysProvidecontractdetailsService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 供货合同货物Controller
 * 
 * @author ruoyi
 * @date 2020-12-13
 */
@Controller
@RequestMapping("/system/providecontractdetails")
public class SysProvidecontractdetailsController extends BaseController
{
    private String prefix = "system/providecontractdetails";

    @Autowired
    private ISysProvidecontractdetailsService sysProvidecontractdetailsService;

    @RequiresPermissions("system:providecontractdetails:view")
    @GetMapping()
    public String providecontractdetails(ModelMap mmap,Long provideContractId)
    {
        mmap.put("provideContractId",provideContractId);
        return prefix + "/providecontractdetails";
    }

    /**
     * 查询供货合同货物列表
     */
    @RequiresPermissions("system:providecontractdetails:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SysProvidecontractdetails sysProvidecontractdetails)
    {
        startPage();
        List<SysProvidecontractdetails> list = sysProvidecontractdetailsService.selectSysProvidecontractdetailsList(sysProvidecontractdetails);
        return getDataTable(list);
    }

    /**
     * 导出供货合同货物列表
     */
    @RequiresPermissions("system:providecontractdetails:export")
    @Log(title = "供货合同货物", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SysProvidecontractdetails sysProvidecontractdetails)
    {
        List<SysProvidecontractdetails> list = sysProvidecontractdetailsService.selectSysProvidecontractdetailsList(sysProvidecontractdetails);
        ExcelUtil<SysProvidecontractdetails> util = new ExcelUtil<SysProvidecontractdetails>(SysProvidecontractdetails.class);
        return util.exportExcel(list, "providecontractdetails");
    }

    /**
     * 新增供货合同货物
     */
    @GetMapping("/add/{provideContractId}")
    public String add(@PathVariable("provideContractId")String provideContractId,ModelMap mmap)
    {
        mmap.put("provideContractId",provideContractId);
        return prefix + "/add";
    }

    /**
     * 新增保存供货合同货物
     */
    @RequiresPermissions("system:providecontractdetails:add")
    @Log(title = "供货合同货物", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SysProvidecontractdetails sysProvidecontractdetails)
    {
        return toAjax(sysProvidecontractdetailsService.insertSysProvidecontractdetails(sysProvidecontractdetails));
    }

    /**
     * 修改供货合同货物
     */
    @GetMapping("/edit/{provideContractDetailsId}")
    public String edit(@PathVariable("provideContractDetailsId") Long provideContractDetailsId, ModelMap mmap)
    {
        SysProvidecontractdetails sysProvidecontractdetails = sysProvidecontractdetailsService.selectSysProvidecontractdetailsById(provideContractDetailsId);
        mmap.put("sysProvidecontractdetails", sysProvidecontractdetails);
        return prefix + "/edit";
    }

    /**
     * 修改保存供货合同货物
     */
    @RequiresPermissions("system:providecontractdetails:edit")
    @Log(title = "供货合同货物", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SysProvidecontractdetails sysProvidecontractdetails)
    {
        return toAjax(sysProvidecontractdetailsService.updateSysProvidecontractdetails(sysProvidecontractdetails));
    }

    /**
     * 删除供货合同货物
     */
    @RequiresPermissions("system:providecontractdetails:remove")
    @Log(title = "供货合同货物", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sysProvidecontractdetailsService.deleteSysProvidecontractdetailsByIds(ids));
    }
}
